package com.beiding.workordersystem.orders.looporder.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.beiding.workordersystem.orders.common.entity.FlowUp;
import com.beiding.workordersystem.system.entity.UserEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@TableName("loop_process")
public class LoopProcess {

    @TableId
    private String id;

    private String orderId;

    private String principalId;

    private Date checkTime;

    private Integer status;

    private Integer times;

    //0 月 ; 1 季 ; 2 年
    private Integer cycle;

    //截止日期
    private Date expirationTime;

    //模板id
    private String templateId;

    private Double commissionFee;

    private Double satrapCommissionFee;

    //主管
    @TableField(strategy = FieldStrategy.IGNORED)
    private String satrapId;

    @TableField(exist = false)
    private String satrapName;

    @TableField(exist = false)
    private LoopOrder order;

    @TableField(exist = false)
    private UserEntity principal;

    //大类
    private String bigType;

    //业务类型
    private String businessType;

    //办理事项
    private String work;

    //业务详情
    private String workDetails;

    @TableField(exist = false)
    private List<ProcessCommission> commissions;

    @TableField(exist = false)
    private List<FlowUp> flowUps;

    private static final Map<Integer, String> codeNameMap = new HashMap<>();

    static {

        //操作逻辑和普通工单一致

        codeNameMap.put(0, "待受理");
        codeNameMap.put(1, "进行中");
        codeNameMap.put(2, "异常");
        codeNameMap.put(3, "完结");
        codeNameMap.put(4, "过期");
    }

    @TableField(exist = false)
    private String statusName;

    public void setStatus(Integer status) {
        this.status = status;
        this.statusName = codeNameMap.get(status);
    }

}
